#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

"""
@author: JoeyZhou
@Tool: PyCharm
@Date: 2020/2/15 3:18 AM
@desc: 封装底层请求方法
"""

import requests
import json
import logging
import logging.config
import os
from os import path


class RequestsBase:
    def __init__(self):
        self.father = '父类'

    def send_post(self, url, headers, data=None)->dict:
        """
        封装post方法
        :param url:
        :param data:
        :return:
        """
        res = requests.post(url=url, json=data, headers=headers).json()
        # return json.dumps(res, indent=4)
        return res

    def send_get(self, url, headers)->dict:
        """
        封装get方法
        :param url:
        :return:
        """
        res = requests.get(url=url, headers=headers).json()
        # return json.dumps(res, indent=4)
        return res


if __name__ == '__main__':
    url = "http://uat-sj-gateway.aihuishou.com/sj-api/auth/login"

    data = {
        "userName": "13969696969",
        "passWord": "qwer1234"
    }

    headers = {
        'Accept': 'application/json',
        'Connection': 'keep-alive',
        'Version': '1.50.0',
        'User-Agent': 'OPTapp/1.30.0 (com.aihuishou.OPTapp.E; build:912; iOS 12.4.0) Alamofire/4.9.0',
        'Platform': 'ios', 'Device-ID': 'EF047AF2-DACA-4BB4-95B3-DD585429C3D5',
        'App-ID': 'pjt042401'
    }

    bv = RequestsBase()
    bv.send_post(url=url, headers=headers, data=data)
    bv.send_get(url=url, headers=headers)
